<?php
/**
 * Created by PhpStorm.
 * User: 1
 * Date: 2017-03-17
 * Time: 15:37
 */

namespace app\src\sunsun\filterVat\action;

use app\src\sunsun\BaseSunsunAction;
use app\src\sunsun\filterVat\logic\FilterVatDeviceEventLogic;
use GatewayClient\Gateway;


/**
 * Class FilterVatDeviceInfoAction
 * tcp 客户端通用操作
 * @package app\src\sunsun\filterVat
 */
class FilterVatDeviceEventAction extends BaseSunsunAction
{
    public function sendMessage($did,$message){
        $this->sendToClient($did,$message);
    }

    /**
     * 获取设备信息
     * @return int
     */
    public function allClientCount(){
        return Gateway::getAllClientCount();
    }


    public function getSession($did){
        $client_id = Gateway::getClientIdByUid($did);
//        return $client_id;
        return Gateway::getSession($client_id[0]);
    }

    /**
     * 清除过期数据
     * @param $dataTimestamp
     * @return array
     */
    public function clearExpiredData($dataTimestamp){
        $result = (new FilterVatDeviceEventLogic())->delete(['create_time'=>['lt',$dataTimestamp]]);
        return $result;
    }
}